<template>
	<view class="home">
		<!--自定义导航栏-->
		<navbar></navbar> 
		<tab :list="tabList" :tabIndex="tabIndex" @tab="tab"></tab>
		<view class="home-list">
			<list :tab="tabList" :activeIndex="activeIndex" @change="change"></list>
		</view>
		
	</view>
</template>

<script>
	import navbar from '@/components/navbar/navbar.vue'
	export default {
		components:{
			navbar
		},
		data() {
			return {
				title: 'Hello',
				tabList:[],
				tabIndex:0,
				activeIndex:0
			}
		},
		onLoad() {
            this.getLabel()
		},
		methods: {
			change(current){
				this.tabIndex = current
				this.activeIndex = current
				//console.log('当前swiper的值',current);
			},
			tab({data,index}){
				this.activeIndex = index
			},
            getLabel() {
				//console.log(this.$api);
				this.$api.get_label({
					name: 'get_label'
				}).then((res) => {
					const {data} = res
					data.unshift({
						name:'全部'
					})
					this.tabList = data
					//console.log(this.tabList);
					
				})
				 
			}
		}
	}
</script>

<style lang="scss">
	page {
		height: 100%;
		display: flex;
	}
	.home {
		display: flex;
		flex-direction: column;
		flex: 1;
		//border: 1px red solid;
		overflow: hidden;
		.home-list {
			flex: 1;
			box-sizing: border-box;
			//border: 1px red solid;
		}
	}
</style>
